Add pre-commit To Prevent Usage of session.query In Core Airflow #45714
Add pre-commit To Prevent Usage of session.query In Core Airflow #45714Prab-27 wants to merge 5 commits intoapache:mainfrom
Conversation
|
a conflict occurred with the images, and I'm not sure how to resolve it. Would you please help me? |
|
as explained in slack - you can replace the confilcting images / .txt with either versions, rebase and re-run pre-commit. The images wil get regenerated to be "latest" automatically (in fact it should happen automatically when you rebase your PR and resolve the conflicts if you did |
| if file_path.name.startswith("test_"): | ||
| continue |
There was a problem hiding this comment.
This check for tests file is not necessary because you have the files to look for at the pre-commit-config.yaml entry
| and isinstance(node.func.value, ast.Name) | ||
| and node.func.value.id == "session" | ||
| ): | ||
| console.print(f"Remove session.query from line {node.lineno}") |
There was a problem hiding this comment.
We are removing the session.query because it is deprecated in SQLAlchemy 2. The message should reflect this and suggest that the user use the new-style query constructs.
There was a problem hiding this comment.
Done !
I tried to write msg from session.query
IS it okay ?
433f780 to
f5d0a67
Compare
|
Could you please clarify it for me? |
Providers should not be part of this. You have to specify that this should check in airflow/ and task_sdk/ and not providers/. |
|
Sorry I have to close this PR |
closes : #45461
Introduce a pre-commit hook to prevent the use of
session.queryin the core Airflow code.This is limited to the source code and excludes the tests/ package.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.